import React from "react";
//导入 store 对象
import store  from "../../redux/store";
import { addAction, asyncAddAction, subAction } from '../../redux/reducers/countReducer'

export default function StateUpdate() {
  return (
    <>
      <button
        onClick={() => {
          //更新状态
          store.dispatch(addAction(10));
          //获取状态
          console.log(store.getState());
        }}
      >
        新增
      </button>
      <button
        onClick={() => {
          store.dispatch(subAction(3));
        }}
      >
        减少
      </button>

      <button
        onClick={() => {
          store.dispatch(asyncAddAction(1));
        }}
      >
        1 秒之后增加 1
      </button>
    </>
  );
}
